﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using FrmTryIF.Ctl.Demo;
using IFViewDetail.KuaiQi;
using HCY.CTP.DBShangZheng;
using FrmTryIF.Ctl.Calc;
using IFClientDLL;

namespace FrmTryIF
{
    public partial class FrmDefault : DevExpress.XtraEditors.XtraForm
    {
        public FrmDefault()
        {
            InitializeComponent();
            ctlPlayMarket1.Enabled = false;
        }
        FrmDemoKuaiQi _frm;
        private FrmCalcImage _frmCalc;
        private void barButtonItem_SelectDemoDay_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            
            FrmSelectDemoDatacs frm = new FrmSelectDemoDatacs();
            frm.Init();
            if (DialogResult.OK == frm.ShowDialog()&&frm.RecID>0)
            {
                _frm = new FrmDemoKuaiQi(ctlPlayMarket1);
                ctlPlayMarket1.Enabled = true;
                _frm.Init(MyDBHelper.GetMarketZiByRecID(frm.RecID), "hcy");
                _frm.Show();
                
            }
        }

        private void FrmDefault_Shown(object sender, EventArgs e)
        {
            //only for test
            _frm = new FrmDemoKuaiQi(ctlPlayMarket1);
            ctlPlayMarket1.Enabled = true;
            _TryIF = _frm.Init(MyDBHelper.GetMarketZiByRecID(29), "hcy");
            
        }

        private void FrmDefault_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ctlPlayMarket1.Player.IsPlaying)
            {
                ctlPlayMarket1.Player.Pause();
                e.Cancel = true;
            }

        }
        ITryIF _TryIF;
        private void barButtonItem_KuaiQi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _frm.Hide();
            _frm.Show();
        }

        private void barButtonItem_CalcImage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_frmCalc == null || _frmCalc.IsDisposed)
            {
                _frmCalc = new FrmCalcImage();
                _frmCalc.Init(_TryIF);
            }
            _frmCalc.Hide();
            _frmCalc.Show();
        }
    }
}